from django_redis import get_redis_connection


class MyRedis:
    def __init__(self):
        self.con = get_redis_connection('default')

    def setstr(self, key, value):
        self.con.set(key, value)
    def delstr(self,key):
        self.con.delete(key)
    def setex(self, key, value, ex):
        self.con.setex(key, ex, value)

    def getstr(self, key):
        val = self.con.get(key)
        if val:
            return val.decode()
        else:
            return ''

    def zset(self, key, value,score):
        return self.con.zincrby(key, score,value)
    def getzstat(self, key):
        return self.con.zrevrange(key, 0, -1)

